package com.yitong;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class demo6 {
    public static void main(String[] args) throws IOException {
        //服务端
        ServerSocket ss =new ServerSocket(1000);
        //接收数据
        Socket s = ss.accept();

        InputStream is = s.getInputStream();

        byte [] bys =new byte[1024];

        int len = is.read(bys);

        System.out.println("接收到客户端的数据："+new String(bys,0,len));

        //写回数据给客户端
        OutputStream os = s.getOutputStream();

        os.write("我已经收到数据了".getBytes());

        ss.close();
    }
}
